1. Field of the Invention
The present invention relates to information handling systems, particularly computer systems for manipulating related data and more particularly to editors for editing related data where the data and relationships can be expressed as a hierarchy, or tree, with data elements forming the nodes and relationships defining the placement of a node within the tree structure. The data and relationships expressed by a tree structure are referred to as "tree structured data".
2. Background of the Invention
Editors are typically comprised of: a user interface to accept commands from the user and display the results of the action; data manipulation processes to perform the necessary editing functions; data storage means to maintain the data and relationships; and (optionally) syntax rules expressing the valid relationships between data nodes for use by the data manipulation processes in validating requested actions.
The manipulation of data represented in a tree structure includes the following functions:
inserting a new data node or set of nodes into the tree structure; PA1 deleting a data node or set of nodes from the tree structure; PA1 copying a data node or set of nodes to a new position in the structure; or PA1 moving a data node or set of nodes to a new position in the structure. PA1 Move, copy, and delete arbitrary selections of nodes within a tree rather than only complete subtrees. PA1 Maintain the relative structure (i.e. nesting and left to right relationships) of both selected and unselected nodes. PA1 Move, copy, and insert selected nodes as the parent of an existing node (i.e. insert the new nodes around the existing node). PA1 Move, copy, and insert selected nodes as all the children of an existing node (i.e. insert the new nodes between the parent node and its children). PA1 Move, copy, and insert selected nodes as children of an existing node. PA1 Maintain the rules concerning the valid structure of the tree as these and other operations are performed. PA1 Store trees using n-ary nodes (i.e. nodes that have an arbitrary number of nodes connected to them), thus saving significant storage space. PA1 Efficiently check that the children of a node within a parse tree are of valid type and in valid order. PA1 Graft a list of subtrees after a specific child of a node, and ensure that the resulting node with its children is syntactically correct. PA1 Replace a list of subtrees below a specific node with a new list of subtrees, and ensure that the resulting node with its children is syntactically correct.
The manipulation functions must preserve any existing relationships between nodes including relationships among a set of nodes to be inserted, deleted, copied or moved.
There have been many systems developed for editing tree structured data. Theme systems, called generally structure editors, have been primarily concerned with editing formally specified programming languages. These editors seek to enforce syntax rules expressing valid relationships between data nodes. Many modern programming languages, and formal languages in general, possess an underlying structure or hierarchy of statements which may be expressed as a tree, known as a parse tree. The relationships forming the tree provide a natural way for manipulating the data.
Programming languages have syntax rules governing the relationships, or trees that are valid for that language. These rules must be followed exactly or the program is meaningless. As a consequence, editors have been developed to assist in the creation and maintenance of programs by enforcing the rules of the language in which the program is written and allowing selection of data to be manipulated based on an understanding of the underlying structure of the program. These editors are known variously as "language based editors" or "syntax-directed editors".
Implementations of editors such as these that are known to the inventors fall into two broad classes. The first provides user interface very similar to that of a standard line or character oriented text editor. Editing works with a textual description of the program, from which the structure is regenerated after each editing operation. If the structure cannot be regenerated, or the regenerated structure is in violation of some syntax rule, the editor either rejects the editing operation or makes its best guess as to how to form the result so that a valid structure may be regenerated.
The advantages of such a scheme are that it is quite general, having no restrictions on what set of characters may be used in editing operations, and that the editing model can be made very familiar to programmers who are currently working with simple text editors. If the editor attempts to create a valid structure from the invalid one the programmer has given it, much of the programmers work can be done automatically as long as the editor generates the structure the programmer had intended. These advantages are also the cause of the scheme's disadvantages, however. The total generality makes it quite simple for a programmer to make the same mistakes that he or she would have made without the syntax-directed editor, and now these mistakes are caught at the moment of entry, interrupting the work, forcing the errors to be corrected. In addition, if the editor attempts to correct the error itself it is likely to do something that, while strictly correct, is not intended by the programmer. If the correction is not in the same direction the programmer had been thinking the programmer must correct not only his or her own error, but also the misinformation the editor generated. This scheme is also fairly inefficient, as little advantage may be taken of the existing structure in order to regenerate the new structure, causing a duplication of effort of the part of the editor. In the process of editing, programmers quite often create incorrect programs as short term intermediate steps in the editing process. This sort of editor either does not allow these steps or fixes them itself, with the possibility (as discussed above) of doing so incorrectly. An example of such an editor is found in the COPE Programming Environment, developed by Richard Conway et al. at Cornell University.
The other class of syntax-directed editors manipulates the structure of the tree directly. The user interface for this class of editors is typically graphical with the user able to work with graphic images representing groups of program statements. The graphic images are displayed as a tree connected according to the specified hierarchical relationships. Only operations that result in a valid tree are allowed to complete. The operations are specified in terms of complete subtrees (a complete subtree consists of a node and all of its children, and their children, and so forth, until no further children are available) and these subtrees may be moved or copied to become subtrees of other nodes, or may be deleted entirely. New nodes or predefined subtrees may be inserted as children of existing nodes as well.
This class of editors is highly efficient, as only the structure of the tree is being manipulated. It also prevents many common errors from ever being made, as only complete structures may be moved around. Unfortunately, it is very restrictive for daily use as an editor. While subtrees are indeed basic to proper manipulation of programs, single complete subtrees are rarely useful. Quite often a programmer wishes to remove a level from the node hierarchy, or insert a level into it. This operation is basic to editing a program beyond the earliest first pass at writing the program which often ends as early as five minutes past the decision to write the program at all. This disadvantage is the main one inhibiting this method from being useful as a basic editing model.
In addition, programmers almost invariably work with several ranges of subtrees (corresponding to ranges of lines) and the simple subtree operations model often doesn't support such operations. An enhancement to some editors represents a subtree following an earlier subtree as the last child of that subtree. This allows a "sequential" list of statements from an arbitrary start position to the end of the sequence at that level of the hierarchy to be represented as a proper subtree. A further enhancement, allowing the final child of a node to be considered detached from the subtree being manipulated, allows sequential statements which can be considered to be partial subtrees, to be moved in one operation with no further restrictions. However, these enhancements are difficult to fit into an editing model based on complete subtrees. Even with these enhancements, the model is still restrictive, for example, allowing nodes only to be added as subtrees of existing nodes, not as parents of existing nodes.
Examples of editors using this model are the Cornell Program Synthesizer, developed by Tim Teitlebaum et al. at Cornell University; and the Xinotech Program Composer, developed by Xinotech Research, Inc.